A former American intelligence analyst and member of the armed forces has pleaded guilty to illegally obtaining classified national defence information and giving it to a reporter.